-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refine select
inline criteria to keep arrange
d computed columns
#1446
Conversation
Thanks for taking a stab at this! |
@mgirlich could you please take a look at this PR too? |
cf4781d
to
e3dc35e
Compare
is_bijective_projection <- function(vars, names_prev) { | ||
vars <- unname(vars) | ||
identical(sort(vars), names_prev) | ||
select_can_be_inlined <- function(lazy_query, vars) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a few tweaks here to hopefully make the logic a bit clearer.
lf <- lazy_frame(x = 1) | ||
|
||
# shouldn't inline | ||
out <- lf %>% mutate(z = 2) %>% arrange(x, z) %>% select(x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is testing the right thing because when I run it, I see:
SELECT `x`
FROM (
SELECT `df`.*, 2.0 AS `z`
FROM `df`
) AS `q01`
Warning message:
ORDER BY is ignored in subqueries without LIMIT
ℹ Do you need to move arrange() later in the pipeline or use window_order() instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe that is the expected behaviour? But definitely worth a snapshot test, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that is expected. I've re-added the snapshot I removed in my prior commit.
Thanks for your work on this @ejneer — it's much appreciated! |
Fixes #1437
This will stop
arrange
d computed columns from being inlined away from subqueries. Of course the subqueryORDER BY
warning will be thrown, but I think that is expected behavior.Before:
Created on 2024-02-07 with reprex v2.0.2
After:
Created on 2024-02-07 with reprex v2.0.2